﻿<!--
  This source code file contains modifications authored by Microsoft Corporation. 
  All such modifications are copyright (c) Microsoft Corporation. All rights reserved.
-->

<rules>
  <rule id="Entry.Core.1007" category="core" target="entry" specificationsection ="2.2.6.2.2" v4specificationsection="6.3" v4specification="odataatom" requirementlevel="must" format="atom">
    <description>An &lt;atom:category&gt; element containing an &lt;atom:term&gt; and an atom:scheme attribute MUST be included if the EntityType of the EntityType instance represented by the &lt;atom:entry&gt; object is part of an inheritance hierarchy.</description>
    <action processor="rng">
      <grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:atom="http://www.w3.org/2005/Atom">
        <start>
          <element>
            <anyName />
            <ref name="anyAttribute" />
            <interleave>
              <!-- Check whether or not atom:category contains atom:term and atom:scheme attributes. -->
              <element name="atom:category">
                <attribute name="term">
                  <text />
                </attribute>
                <attribute name="scheme">
                  <text />
                </attribute>
              </element>
              <zeroOrMore>
                <ref name="anyElement_other_than_atom_category" />
              </zeroOrMore>
            </interleave>
          </element>
        </start>
        <define name="anyContent">
          <zeroOrMore>
            <choice>
              <attribute>
                <anyName />
              </attribute>
              <text />
              <ref name="anyElement" />
            </choice>
          </zeroOrMore>
        </define>
        <define name="anyAttribute">
          <zeroOrMore>
            <choice>
              <attribute>
                <anyName />
              </attribute>
            </choice>
          </zeroOrMore>
        </define>
        <define name="anyElement">
          <element>
            <anyName />
            <zeroOrMore>
              <choice>
                <attribute>
                  <anyName />
                </attribute>
                <text />
                <ref name="anyElement" />
              </choice>
            </zeroOrMore>
          </element>
        </define>
        <define name="anyElement_other_than_atom_category">
          <element>
            <choice>
              <anyName>
                <except>
                  <nsName ns="http://www.w3.org/2005/Atom" />
                </except>
              </anyName>
              <nsName ns="http://www.w3.org/2005/Atom">
                <except>
                  <name>atom:category</name>
                </except>
              </nsName>
            </choice>
            <ref name="anyContent" />
          </element>
        </define>
      </grammar>
    </action>
    <errormessage>An &lt;atom:category&gt; element containing an &lt;atom:term&gt; and an atom:scheme attribute MUST be included if the EntityType of the EntityType instance represented by the &lt;atom:entry&gt; object is part of an inheritance hierarchy.</errormessage>
  </rule>
</rules>